#include "CheckBox.h"
#include<iostream>

NAMESPACE_HEAD(mk)
NAMESPACE_HEAD(controls)

CheckBox::CheckBox(bool initialState)
{
	switchvalue = initialState;
}
void CheckBox::BindVariable(SharedPtrBool ptargetVar_ptr)
{
	targetVar_ptr = ptargetVar_ptr;
	switchvalue = *targetVar_ptr;
}
void CheckBox::On_Clicked()
{
	if(targetVar_ptr == NULL)
		return;
	switchvalue = !switchvalue;
	*targetVar_ptr = switchvalue;
}
void CheckBox::Draw()
{
	if(switchvalue == true)
		glColor3f(0,0,1.0);
	else
		glColor3f(1.0,0,0);
	glBegin(GL_QUADS);
	glVertex2f(x,y);
	glVertex2f(x + width, y);
	glVertex2f(x +width, y + height);
	glVertex2f(x, y + height);
	glEnd();
}
NAMESPACE_END()
NAMESPACE_END()